package com.spundhan.xtrac.adapters;

import java.util.List;

import com.spundhan.xtrac.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class TripsAdapter extends ArrayAdapter<String> {

	Context thisContext;
	
	int inflatableRes;
	
	LayoutInflater inflater;
	
	public TripsAdapter(Context context, int resource, int textViewResourceId,
			List<String> objects) {
		super(context, resource, textViewResourceId, objects);
		
		thisContext = context;
		inflatableRes = resource;
		inflater = (LayoutInflater) thisContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
				
	}
	
	@Override
	public int getCount() {
		return super.getCount();
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		ViewHolder holder = null;
		try{
			
			if(convertView == null){
				
				holder = new ViewHolder();
				convertView = inflater.inflate(inflatableRes, null);
				convertView.setTag(holder);
				
			}else{
				
				holder =  (ViewHolder) convertView.getTag();
			}
			
			holder.tripName = (TextView) convertView.findViewById(R.id.trip_name);
			
		}catch(Exception e){
			
			e.printStackTrace();
		}
		
		
		
		return super.getView(position, convertView, parent);
	}
	
	
	public class ViewHolder{
		
		TextView tripName;
	}

}
